package com.siss.tenancy.controller;

import com.alibaba.cloud.nacos.NacosConfigManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class UserConfigController {

    @Autowired
    private NacosConfigManager nacosConfigManager;

    @Autowired
    private Environment environment;

    @Value("${user.name:zz}")
    String userName;

    @Value("${user.age:14}")
    Integer age;

    @Value("${service.database:没有}")
    String commonInfo;

    private static final Logger LOGGER = LoggerFactory.getLogger(UserConfigController.class);


    @GetMapping("/user")
    public String simple() {
        return "Hello Nacos Config!" + "Hello " + userName + " " + age + "!" + nacosConfigManager.getConfigService();
    }

    @GetMapping("/common")
    public String common() {
        return commonInfo;
    }

}
